import java.io.File;
import java.io.IOException;

import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

import MainMethods.Archive;
import MainMethods.FileWr;
import MainMethods.sendEmail;
import Tests.Test;

public class Runner {
	static Test test = new Test();
	static FileWr file = new FileWr();
	static sendEmail mail = new sendEmail();
	static Archive arch = new Archive();

	public static void main(String[] args) throws InterruptedException,
			IOException, NoSuchElementException {
		// testing in firefox
		// WebDriver driverFox = new FirefoxDriver();
		// driverFox.manage().window().maximize();
		// file.writeToFile("report.txt", "firefoxReport");
		// test.testing(driverFox, file, "firefoxReport");
		// arch.addToZip(new File("firefoxReport"), "firefoxReport.zip");
		// mail.sendToAll("firefoxReport.zip");

		// testing in chrome
		System.setProperty("webdriver.chrome.driver", "chromedriver.exe");
		WebDriver driverChr = new ChromeDriver();
		driverChr.manage().window().maximize();
		file.writeToFile("report_signup.txt", "chromeReport");
		test.testSignUp(driverChr, file, "chromeReport");
		file.writeToFile("report_music.txt", "chromeReport");
		test.testMusic(driverChr, file, "chromeReport");
		file.writeToFile("report_movies.txt", "chromeReport");
		test.testMovies(driverChr, file, "chromeReport");
		file.writeToFile("report_books.txt", "chromeReport");
		test.testBooks(driverChr, file, "chromeReport");
		file.writeToFile("report_soft.txt", "chromeReport");
		test.testSoft(driverChr, file, "chromeReport");
		file.writeToFile("report_account.txt", "chromeReport");
		test.testAccount(driverChr, file, "chromeReport");
		file.writeToFile("report_CancelSearch.txt", "chromeReport");
		test.testCancelSearch(driverChr, file, "chromeReport");
		arch.addToZip(new File("chromeReport"), "chromeReport.zip");
		driverChr.close();
		mail.sendToAll("chromeReport.zip");

		// testing IE
		System.setProperty("webdriver.ie.driver", "IEDriverServer.exe");
		WebDriver driverIE = new InternetExplorerDriver();
		driverIE.get("http://staging.pf-ayeplay.jomediainc.com/signup?sf=eight_r");
		driverIE.manage().window().maximize();
		file.writeToFile("report_signup.txt", "IEReport");
		test.testSignUp(driverChr, file, "IEReport");
		file.writeToFile("report_music.txt", "IEReport");
		test.testMusic(driverChr, file, "IEReport");
		file.writeToFile("report_movies.txt", "IEReport");
		test.testMovies(driverChr, file, "IEReport");
		file.writeToFile("report_books.txt", "IEReport");
		test.testBooks(driverChr, file, "IEReport");
		file.writeToFile("report_soft.txt", "IEReport");
		test.testSoft(driverChr, file, "IEReport");
		file.writeToFile("report_account.txt", "IEReport");
		test.testAccount(driverChr, file, "IEReport");
		file.writeToFile("report_CancelSearch.txt", "IEReport");
		test.testCancelSearch(driverChr, file, "IEReport");
		arch.addToZip(new File("IEReport"), "IEReport.zip");
		driverIE.close();
		mail.sendToAll("IEReport.zip");

		// testing safari
		// WebDriver driverSaf = new SafariDriver();
		// driverSaf.manage().window().maximize();
		// file.writeToFile("report.txt", "SafReport");
		// test.testing(driverSaf, file, "SafReport");
		// arch.addToZip(new File("SafReport"), "SafReport.zip");
		// mail.sendToAll("SafReport.zip");

		// testing opera
		// DesiredCapabilities caps = DesiredCapabilities.opera();
		// caps.setCapability("opera.profile", new OperaProfile(
		// "C:/Users/Ivan/AppData/Local/Temp"));
		// caps.setCapability("opera.binary",
		// "C:/Program Files (x86)/Opera/19.0.1326.59/opera.exe");
		// //caps.setCapability("opera.host", "127.0.0.1");
		// //caps.setCapability("opera.port", -1);
		// //caps.setCapability("opera.arguments", "-maximized");
		// // System.setProperty("os.name", "windows");
		// WebDriver driverOp = new OperaDriver(caps);
		// file.writeToFile("report.txt", "OpReport");
		// test.testing(driverOp, file, "OpReport");
		// arch.addToZip(new File("OpReport"), "OpReport.zip");
		// mail.sendToAll("OpReport.zip");

	}

}
